import Pubsub from 'pubsub-js'
import React, { useEffect, useState } from 'react'
import Item from './Item'

export default function List() {
    const[searchList,setSearchList] =useState({isInit: false, isSearch: true, data: []})

    useEffect(()=>{
        Pubsub.subscribe('github',(_,data)=>{
            setSearchList(data)
        })
    },[])

  return (
        <div>
            {

              searchList.isInit ? 请加载数据:
                  searchList.isSearch ?正在加载数据:
                        searchList.map(item=>{
                            return <Item key={item.id} {...item}/>
                        })
            }
        </div>
  )
}
